﻿<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="PollSystem._Default" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">

    <%--•	Display random questions – the system should display 3 random questions along with their answers. 
    Ensure you handle properly any special HTML characters, e.g. a question could say 
    "Do you know how to work with the <div> and <span> tags in HTML?" and should be displayed correctly.--%>

    <asp:ListView ID="ListViewQuestions" ItemType="PollSystem.Model.Question"
        runat="server">

        <LayoutTemplate>
            <div id="itemPlaceholder" runat="server"></div>
        </LayoutTemplate>

        <ItemTemplate>
            <div class="question">
                <%#: Item.QuestionText %>
            </div>

            <ul>
                <asp:Repeater ID="RepeaterAnswers" DataSource="<%# Item.Answers %>"
                    runat="server" ItemType="PollSystem.Model.Answer">
                    <ItemTemplate>
                        <li><%#: Item.AnswerText %> --> <%# Item.Votes %>
                            <asp:LinkButton ID="LinkButtonVote" runat="server" Text="Vote"
                                CommandName="Vote" CommandArgument="<%# Item.AnswerId %>"
                                OnCommand="LinkButtonVote_Command" />
                        </li>

                    </ItemTemplate>
                </asp:Repeater>
            </ul>

        </ItemTemplate>

    </asp:ListView>

</asp:Content>